package com.personnalManagerSystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.personnalManagerSystem.model.User;
import com.personnalManagerSystem.mapper.UserMapper;
import com.personnalManagerSystem.model.User2;
import com.personnalManagerSystem.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liqing
 * @since 2022-03-27
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(String username, String password) {
        return userMapper.login(username,password);
    }

    @Override
    public List<User2> selectUserDepartmentPosition(QueryWrapper<User2> wrapper) {
        return userMapper.selectUserDepartmentPosition(wrapper);
    }
    //查询公司总人数
    @Override
    public Map<String, Integer> selectAllUser() {
        int sum = userMapper.selectAllUser();
        Map<String,Integer> sumMap = new HashMap<>();
        sumMap.put("allUser",sum);
        return sumMap;
    }

    //验证用户名的唯一性
    @Override
    public User queryUsername(String username) {
        return userMapper.queryUsername(username);
    }
}
